﻿using System;
using System.Web;

namespace TMT.Admin.Handler
{
    public class ActionHandler : IHttpHandler
    {
        /// <summary>
        /// You will need to configure this handler in the web.config file of your 
        /// web and register it with IIS before being able to use it. For more information
        /// see the following link: http://go.microsoft.com/?linkid=8101007
        /// </summary>
        #region IHttpHandler Members

        public bool IsReusable
        {
            // Return false in case your Managed Handler cannot be reused for another request.
            // Usually this would be false in case you have some state information preserved per request.
            get { return true; }
        }

        public void ProcessRequest(HttpContext context)
        {
            HttpRequest req = HttpContext.Current.Request;
            HttpResponse res = HttpContext.Current.Response;

            // Extract the 'action' parameter from the request, if any.
            string view = req["view"];
            //write your handler implementation here.
            switch (view.ToLower())
            {
                case "user":
                    res.Redirect("~/UserAccount/UserManagement.aspx");
                    return;
                case "page":
                    res.Redirect("~/Page/PageManagement.aspx");
                    return;
                default:
                    break;
            }
            
            res.Redirect("default.aspx");
        }

        #endregion
    }
}
